using System;
using System.Collections;

namespace Slaks.DocumentSerialization.TermIdInfo
{
	/// <summary>
	/// Compares id in ascending order. The smallest id will be the first
	/// </summary>
	public class IdComparer : IComparer
	{
		public int Compare(TermIdInfoElement x, TermIdInfoElement y)
		{
			if (x.Id < y.Id) return -1;
			else if (x.Id == y.Id) return 0;
			return 1;
		}

		public int Compare(object x, object y)
		{
			TermIdInfoElement xx = x as TermIdInfoElement;
			TermIdInfoElement yy = y as TermIdInfoElement;
			if (xx == null || yy == null) throw new ArgumentException("Object passed for comparison is not TermIdInfoElement");
			return Compare(xx, yy);
		}
	}
}